package tool.lib;

import android.content.Context;
import android.widget.Toast;

/**
 * Created by youyi on 2015/3/21.
 */
public class ToastTool {
    private static ToastTool instance=null;
    private Toast toast;
    private Context context;
    public ToastTool(Context context)
    {
        this.context=context;
    }
    public static void showToast(String text)
    {
        if(instance.toast==null)
            instance.toast=Toast.makeText(instance.context,text,Toast.LENGTH_SHORT);
        else {
            instance.toast.setText(text);
        }
        instance.toast.show();
    }
    public static void init(Context context)
    {
        instance=new ToastTool(context);
    }
    public static ToastTool getInstance()
    {
        return instance;
    }
    public static void release()
    {
        instance=null;
    }
}
